package com.itheima.test8;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;
import java.util.UUID;

/*
下载小说
 */
public class ClientTest {

    public static void main(String[] args) throws IOException {

        Socket socket = new Socket("127.0.0.1", 10002);

        InputStream is = socket.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("day16\\download\\"+ UUID.randomUUID()+".txt"));
        byte[] bytes=new byte[1024];
        int len;
        while((len=bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
        }
        bos.flush();
        bos.close();
        socket.close();
    }
}
